#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

ll a, b;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> a >> b;
  if (a % 2 == 0 && a * a == 4 * b) {
    cout << "inf";
    return 0;
  }
  ll cnt = 0;
  ll c = sqrt(b + 0.5);
  if (c * c == b) cnt++;
  for (ll i = sqrt(b) + 1; i * 2 < a && i * i > b; i++) {
    ll x = b - i * i;
    ll y = 2 * i - a;
    if (x && x % y == 0) cnt++;
  }
  for (ll i = a / 2 + 1; i * i < b; i++) {
    ll x = b - i * i;
    ll y = 2 * i - a;
    if (x % y == 0) cnt++;
  }
  cout << cnt;
  return 0;
}